package org.nViron.nvData;

//~--- non-JDK imports --------------------------------------------------------

import java.util.Iterator;

import org.nViron.nvParams.nvContextParamMgr.CONTEXTPARAM;
import org.nViron.nvSim.nvObjectMgr;
import org.nViron.nvSim.nvSimulator;

/**
 * Manages and updates data sources
 * @author Roland Haring <p>
 * <script type="text/javascript" src="http://www.ohloh.net/p/376434/widgets/project_basic_stats.js"></script>
 */
public class nvDataSourceMgr extends nvObjectMgr {
    public nvDataSourceMgr(nvSimulator simulator) {
        super(simulator);
    }

    public boolean doesProvide(CONTEXTPARAM contextParam) {
            for (Iterator i = getObjects().values().iterator(); i.hasNext(); ) {
            nvDataSource source = (nvDataSource)i.next();
            if (source.doesProvide(contextParam)) {
                return true;
            }
        }

        return false;
    }

    public nvDataSource getDataSource(int index) {
        return (nvDataSource) getObject(index);
    }

    @Override
    public void update(float timeStep) {
        for (Iterator i = getObjects().values().iterator(); i.hasNext(); ) {
            nvDataSource source = (nvDataSource) i.next();
            source.updateUserPos(getSimulator().getUserPosition());
            source.updateCameraPos(getSimulator().getCameraPosition());
        }
    }
}



